<template>
  <view class="tabBox">
    <swiper class="swiper" next-margin="25rpx" previous-margin="30rpx">
      <swiper-item
        v-for="(e,i) in tabmenu"
        :key="i"
        :class="['swiperitem',{active:current == i}]"
        @click="hangleClickSwiper(i)"
      >
        <view class="icons">
          <i :class="['iconfont',e.icon]"></i>
        </view>
        <text>{{e.name}}</text>
      </swiper-item>
    </swiper>
    <view class="con">
      <realname id="realname-box" :projectInfo="projectInfo" v-if="current == 0"></realname>
      <dust id="dust-box" :projectInfo="projectInfo" v-if="current == 1"></dust>
      <video id="video-box" :projectInfo="projectInfo" v-if="current == 2"></video>
    </view>
  </view>
</template>
<script>
import realname from "./realname";
import dust from "./dust";
import video from "./video";
export default {
  components: { realname, dust, video },
  data() {
    return {
      current: 0,
      projectInfo: { appID: "", appToken: "", projectId: "" },
      tabmenu: [
        { name: "实名制管理", icon: "iconshimingzhi" },
        { name: "扬尘环境管理", icon: "iconyangchen" }
        // {name:'视频监控', icon:'iconshipinjiankong'},
        // {name:'塔吊监控', icon:'icontadiaocopy'},
        // {name:'升降机监控', icon:'iconshengjiangji'},
        // {name:'安全帽', icon:'iconanquanmao'},
        // {name:'深基坑', icon:'iconshenjikengjiance'},
        // {name:'BMI', icon:'iconBMI'}
      ]
    };
  },
  onLoad(option) {
    this.current = option.tab;
    this.projectInfo.appID = option.appid;
    this.projectInfo.appToken = option.apptoken;
    this.projectInfo.projectId = option.projectid;
  },
  watch: {
    current: {
      handler(newdata, olddata) {
        uni.setNavigationBarTitle({
          title: this.tabmenu[newdata].name
        });
      },
      deep: true
    }
  },
  methods: {
    hangleClickSwiper(i){
      this.current = i
    },
  }
};
</script>
<style lang="scss">
page {
  min-height: 100%;
  height: auto;
}
.tabBox {
  padding: 1rem 0;
  min-height: 100%;
  position: relative;
  &:before {
    content: "";
    top: 0;
    left: 0;
    width: 100%;
    background: #3271ef;
    height: 30%;
    position: absolute;
  }
  swiper {
    .swiperitem {
      background: transparent;
      width: 25% !important;
      &.active {
        .icons {
          background: #fff;
          i {
            color: #3271ef;
          }
        }
      }
      .icons {
        width: 40px;
        height: 40px;
        border: 1px solid #fff;
        border-radius: 0.4rem;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0 auto;
        i {
          color: #fff;
          font-size: 1.2rem;
        }
      }
      text {
        color: #fff;
        font-size: 0.6rem;
        display: block;
        padding-top: 0.2rem;
        text-align: center;
        letter-spacing: 1px;
      }
    }
  }
  .con {
    margin-top: 1rem;
  }
}
#realname-box {
  min-height: 100%;
  .realname-box {
    padding: 0rem 30rpx 1rem;
    margin-top: -90px;
    .bg {
      position: relative;
      background: #fff;
      border-radius: 0.5rem;
      box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
      padding: 1rem 0.8rem 0.8rem;
    }

    .tophead {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: space-between;
      h4 {
        font-weight: normal;
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 1px;
      }
      .tips {
        font-size: 0.6rem;
      }
      .alink {
        position: absolute;
        top: 0.15rem;
        right: 0;
        line-height: 0.8rem;
        font-size: 0.6rem;
        color: #56a6ff;
        border: 1px solid #56a6ff;
        border-radius: 1rem;
        padding: 0.1rem 0.4rem;
      }
    }
    .canbgcon {
      .canbg,
      canvas {
        height: 400upx;
        width: 600upx;
        margin: 0 auto;
      }
    }
    .realname-info {
      @extend .bg;
      h4 {
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 1px;
        text-align: center;
      }
      .iconlist {
        justify-content: space-between;
        display: flex;
        align-items: center;
        padding: 1rem 0.7rem 0.3rem;
        .item {
          i {
            &.iconrenyuan {
              font-size: 1.3rem;
            }
            background: #3271ef;
            color: #fff;
            border-radius: 0.3rem;
            font-size: 1.6rem;
            width: 2.5rem;
            height: 2.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
          }
          span {
            font-size: 0.7rem;
            display: block;
            text-align: center;
            padding-top: 0.2rem;
          }
        }
      }
    }
    .todayMain {
      display: flex;
      padding: 0.4rem;
      .item {
        flex: 1;
        position: relative;
        padding: 0.3rem;
        & > image {
          box-shadow: 0 0 35px rgba(201, 230, 255, 0.4);
        }
        .itemcon {
          position: absolute;
          left: 0.9rem;
          top: 0.8rem;
          right: 0.9rem;
          .top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            .title {
              text {
                color: #409be5;
                padding-left: 0.2rem;
              }
            }
            .num {
              color: #409be5;
              text {
                color: #adadad;
              }
            }
          }
          .canvasbg {
            padding: 15px 1.7rem;
          }
        }
      }
      .item2 {
        .title {
          color: #fff !important;
          text {
            color: #fff !important;
          }
        }
        .num {
          color: #fff !important;
          text {
            color: #fff !important;
          }
        }
      }
    }
    .projectOnline {
      padding: 0.5rem 0.6rem;
      text-align: left;
      .proCon {
        padding-top: 1.3rem;
        display: flex;
        align-items: center;
        .proCans {
          width: 40%;
          flex: 1;
          padding: 0 1.5rem;
        }
        .proTags {
          width: 60%;
          flex: 1;
          padding-top: 0.2rem;
          position: relative;
          padding-left: 2rem;
          .tagitem {
            display: flex;
            align-items: center;
            .iok {
              border-radius: 50%;
              padding: 0 0.4rem;
              display: flex;
              justify-content: center;
              align-items: center;
              width: 1.5rem;
              height: 1.5rem;
              & > image {
                width: 100%;
              }
            }
            text {
              padding-left: 0.5rem;
            }
          }
          view.tagitem + view.tagitem {
            padding-top: 1rem;
          }
        }
        .proTags:before {
          content: "";
          position: absolute;
          width: 1px;
          height: 50%;
          top: 1rem;
          left: 0;
          background: #d8d9da;
        }
      }
      .splite {
        width: 80%;
        margin: 0 auto;
        padding-top: 1.5rem;
      }
    }
    .oneWeekReport {
      @extend .bg;
      margin-top: 1rem;
      .top {
        @extend .tophead;
      }
      .canbgcon {
        margin-top: 1rem;
      }
    }
    .workChart,
    .groupChart {
      @extend .bg;
      margin-top: 1rem;
      .top {
        @extend .tophead;
      }
      .canbgcon {
        margin-top: 1rem;
      }
    }
    .online-box {
      @extend .bg;
      margin-top: 1rem;
      .canbgcon2 {
        display: flex;
        padding: 0 15upx;
        justify-content: space-between;
        .canbg2 {
          flex: 1;
          width: 260upx;
          height: 260upx;
          display: flex;
          align-items: center;
          justify-content: center;
          .bg {
            background: #f1f6fa;
            border-radius: 50%;
            height: 260upx;
            width: 260upx;
            overflow: hidden;
            position: relative;
            .bg2 {
              background: #fff;
              border-radius: 50%;
              position: absolute;
              width: 240upx;
              height: 240upx;
              top: 10upx;
              left: 10upx;
              .chart-box {
                width: 230upx;
                height: 230upx;
                position: absolute;
                left: 5upx;
                top: 5upx;
                canvas {
                  width: 230upx;
                  height: 230upx;
                }
              }
            }
          }
        }
        canvas {
          margin: 0 auto;
        }
      }
      .texts {
        display: flex;
        align-items: center;
        padding-top: 0.5rem;
        .txt {
          flex: 1;
          text-align: center;
          color: #909090;
        }
      }
    }
    .kaiqi {
      @extend .bg;
      padding-bottom: 1.5rem;
      margin-top: 0.8rem;
      .data-box {
        .top {
          @extend .tophead;
        }
        .d1 {
          color: #909090;
          font-size: 0.6rem;
          display: flex;
          align-items: center;
          &.dt {
            margin-top: 1.5rem;
          }
          &.dtt {
            margin-top: 1rem;
          }
          .tt {
            width: 2.8rem;
          }
          .lbg {
            flex: 1;
            position: relative;
            height: 0.35rem;
            overflow: hidden;
            view {
              position: absolute;
              height: 100%;
              left: 0;
              border-radius: 0.8rem;
            }
            .blue {
              background: #56a6ff;
            }
            .green {
              background: #1abb69;
            }
            .orange {
              background: #ee7373;
            }
          }
          .num {
            margin-left: 0.5rem;
          }
        }
      }
    }
  }
}
#dust-box {
  min-height: 100%;
  .dust-box {
    padding: 0rem 30rpx 1rem;
    margin-top: -90px;
    .bg {
      position: relative;
      background: #fff;
      border-radius: 0.5rem;
      box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
      padding: 1rem 0.8rem 0.8rem;
    }
    .top {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: space-between;
      h4 {
        font-weight: normal;
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 1px;
      }
      .tips {
        font-size: 0.6rem;
      }
      .alink {
        position: absolute;
        top: 0.15rem;
        right: 0;
        line-height: 0.8rem;
        font-size: 0.6rem;
        color: #56a6ff;
        border: 1px solid #56a6ff;
        border-radius: 1rem;
        padding: 0.1rem 0.4rem;
      }
    }
    .dust-item-box {
      @extend .bg;
      .cirs {
        margin-top: 0.5rem;
        display: flex;
        .item {
          flex: 1;
          canvas {
            width: 200upx;
            height: 200upx;
          }
          .t1 {
            display: block;
            text-align: center;
            font-size: 0.8rem;
          }
          .t2 {
            display: block;
            text-align: center;
            font-weight: 700;
          }
        }
      }
      .hm1 {
        margin-top: 1rem;
        &:first-child {
          margin-top: 1.5rem;
        }
        text {
          font-size: 0.8rem;
          color: #888888;
        }
        .pros {
          margin-top: 0rem;
          display: flex;
          align-items: center;
          .lbg {
            height: 0.4rem;
            overflow: hidden;
            border-radius: 0.8rem;
            &.blue {
              background: #56a6ff;
            }
            &.green {
              background: #1abb69;
            }
            &.red {
              background: #ee7373;
            }
          }
          .num {
            color: #888;
            margin-left: 0.5rem;
            text-align: left;
            flex-shrink: 0;
          }
        }
      }
    }
    .dust-item-box + .dust-item-box {
      margin-top: 1rem;
    }
  }
}
</style>